package de.fhk.fst.dvr.helper

import java.sql.Timestamp
import java.text.SimpleDateFormat

class DateTimeConverterService {

  static SimpleDateFormat sdfTime = new SimpleDateFormat("HH:mm")
  static SimpleDateFormat sdfDay = new SimpleDateFormat("dd.MM.yyyy")
  static transactional = false

  def convertToDateString( Timestamp timestamp ) {
    return sdfDay.format(timestamp)
  }

  def convertToTimeString( Timestamp timestamp ) {
    return sdfTime.format(timestamp)
  }

  def removeSecondsFromDate( Date date ) {
    def cal = Calendar.getInstance()
    cal.setTime date
    cal.set Calendar.SECOND, 0
    cal.set Calendar.MILLISECOND, 0
    return cal.getTime()
  }
}
